<template>
  <Content :style="{padding: '10px 30px',background:'#fff'}">
    <Row>
      <Col span="24" class="flex-inline">
        <span class="title">企业类型:</span>
        <Tabs class="tagsList" v-model="currentCorporateType" @on-click="getCorporateType">
          <TabPane class="tagItem" v-for="(item,index) in CorporateType"  :label="item.name" :name="item.name" :key="index" ></TabPane>
        </Tabs>
      </Col>
      <Col span="24" class="flex-inline">
        <span class="title">企业分类:</span>
        <Tabs class="tagsList" v-model="currentIndustryName" @on-click="getIndustryName">
          <TabPane class="tagItem" v-for="(item,index) in IndustryName"  :label="item" :name="item" :key="index" ></TabPane>
        </Tabs>
        <Button type="primary" large @click="declaration =true "  style="float: right">企业申报</Button>
      </Col>

    </Row>
    <Row style="margin-top: 20px" :gutter="24">
            <Col span="5"><Input type="text" placeholder="请输入企业名称" v-model="InformationName"/></Col>
            <Col span="4" ><Button type="primary" @click="getLibraryData">搜索</Button></Col>
    </Row>
    <Row style="margin-top: 20px">
      <Col span="24">
        <Table :columns="columnList" :data="corporateDataList" size="large" :loading="loading"></Table>
        <Modal v-model="connection" title="联系">
          <Row>
            <Col>
              <h3>联系人:李腾飞</h3>
              <h3>联系电话:13522868331</h3>
            </Col>
          </Row>
        </Modal>
        <div style="float: right; margin: 10px">
          <Page :total="total" :current.sync="currentPage" :page-size="pageSize" show-total @on-change="changeLibraryPage" show-elevator></Page>
        </div>
      </Col>
    </Row>
    <Modal v-model="declaration" title="企业申报">
<enterprise-declaration/>
    </Modal>
  </Content>
</template>

<script>
  import EnterpriseDeclaration from './EnterpriseDeclaration'
  export default {
    name: "EnterpriseLibrary",
    data(){
      return{
          loading:false,
        total:0,
        pageNum:1,
        currentPage:1,
        pageSize:10,
        currentCorporateType:"",//当前选择的企业类型
        currentIndustryName:"",//当前选择的企业分类
          InformationName:'',//企业名称
          declaration:false,//企业申报弹框
          // queryLibraryTypeData:{
              CorporateType:[],
            IndustryName:['全部','科技','医药','服务','服装','金属','加工','制造','研究'],
        // },
        columnList:[

          {
            title:'企业类型',
            key:'corporateTypeName',
              align:'center'
          },
          {
            title:'企业行业',
            key:'corporateIndustryName',
              align:'center'
          },{
            title:'企业名称',
            key:'corporateInformationName',
                align:'center'
          },{
            title:'地区',
            key:'regionName',
                align:'center',
                width:100
          },{
            title:'成立时间',
            key:'establishedDate',
                align:'center'
          },{
            title:'企业产品',
            key:'corporateIndustryName',
                align:'center'
          },
          {
            title:'是否上市',
            key:'isPublicName',
              align:'center',
              width:100
          },
            {
                title:'联系',
                align:'center',
                width:100,
                render:(h,params)=>{
                    return h("Button",{
                        props:{
                            type:'primary',
                            icon:'ios-call',

                        },
                        on:{
                            click:()=>{
                                 this.connection=true
                            }
                        }
                    })
                }
            }
        ],
          connection:false,
          corporateDataList:[],

      }
    },
      components:{
          EnterpriseDeclaration
      },
    methods:{
        getCorporateType(name){
        this.currentCorporateType=name
      },
        getIndustryName(name){

        this.currentIndustryName=name
      },
      //获取企业类型显示信息
      getLibraryType(){
          let url="http://10.10.0.55:8080/consulting-library/api/corporate/queryCorporateTypeDisplay"
          this.$http({
              method: 'POST',
              url:url,
              data:{}
          }).then(response =>{
              let result=response.data
              if (result.meta.success){
                  this.CorporateType=result.data.list



              } else {
                  console.log("获取信息失败")
              }
              console.log(this.CorporateType)

              console.log(this.CorporateType[1].name)
          })
      },
      //获取企业数据
      getLibraryData(){
        let url=this.$url.baseUrl+'/consulting-library/api/corporate/queryCorporateInformation'
        this.$http({
            method:'POST',
            url:url,
          data:{
              "pageNum": this.pageNum,
              "pageSize": this.pageSize,
              "paramModel": {
                  "corporateIndustryName":(this.currentIndustryName=='全部'?"":this.currentIndustryName),
                  "corporateInformationName":this.InformationName,
                  "corporateTypeName": (this.currentCorporateType=='全部'?"":this.currentCorporateType)
              }

          }
        }).then(response =>{
          let result=response.data
          if (result.meta.success){
            this.corporateDataList=result.data.list
            this.total=result.data.total
          }
        })
      },
        changeLibraryPage(index){
        this.pageNum=index
        this.getLibraryData()
      }
    },
    watch:{
        currentCorporateType(){
        this.getCorporateType(this.currentCorporateType)
        this.getLibraryData()
      },
        currentIndustryName(){
        this.getIndustryName(this.currentIndustryName)
        this.getLibraryData()
      },
    },
    created(){
      this.getLibraryData()
        this.getLibraryType()
    }

  }
</script>

<style>
  .flex-inline{
    display: flex;
  }
  .title{
    font-size: 16px;
    font-weight: 700;
    line-height: 40px;
    margin-right: 10px;
  }
  .tagsList{
    float: left;
  }
  .ivu-tabs-nav-scroll{
    width: 830px;
  }
  .tagItem{
    padding: 0 10px;
    line-height: 40px;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    box-sizing: border-box;
    border: none;
    background: #ffffff;
    height: 40px;
    margin: 0px;
  }
  .tagsList .ivu-tabs-bar{
    margin-bottom: 0px;
    border:none;
  }
  .tagsList .ivu-tabs-content{
    display: none;
  }
  .ivu-form-item{
    display: inline-block;
    margin-right: 20px;
  }
  .ivu-btn > .ivu-icon{
    line-height: 1;
    font-size: 20px;
  }
</style>
